#include <stdio.h>
int fun(int n)
{
	int n1,sum=1;
	while(n!=0)
	{
		n1=n%10;
		if(n1!=0) sum*=n1;
		n=n/10;
	}
	return sum;	
}
int main()
{
	int n;
	scanf("%d",&n);
	while(n>=10)
	{
		n=fun(n);
    }
    printf("%d",n);
	return 0;
 } 
